# Definition for a binary tree node.
class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

root=TreeNode(1,None,None)
root.right=TreeNode(2,None,None)
root.right.left=TreeNode(3,None,None)

def dfs(root,res):
    if root.left==None and root.right==None:
        print(root.val)
        res.append(root.val)
        return None
    if root.left!=None:
        dfs(root.left,res)
    res.append(root.val)
    if root.right!=None:
        dfs(root.right,res)
    print(root.val)


def inorderTraversal(root):
    res=[]
    dfs(root,res)
    print(res)

inorderTraversal(root)